package com.mmp.main.autogenerators;

import org.springframework.beans.factory.annotation.Autowired;

import com.mmp.main.DB.DBQueryManager;

public class JobOrderNoGenerator {

	@Autowired
	protected DBQueryManager dbQueryManager;

	// concurrency control not handled properly
	/*
	 * public String generateJobOrderNo(int siteId) { Date now = new Date();
	 * String yy = new SimpleDateFormat("yy").format(now); String mm = new
	 * SimpleDateFormat("MM").format(now); int serial = getJobOrderCount(siteId,
	 * Integer.parseInt("20" + yy), Integer.parseInt(mm)) + 1; Common.log("" +
	 * (Integer.parseInt(yy + mm) * 1000 + serial)); return "" +
	 * (Integer.parseInt(yy + mm) * 1000 + serial); }
	 * 
	 * private synchronized int getJobOrderCount(int siteId, int month, int
	 * year) { String jpql =
	 * "SELECT COUNT(j.id) FROM JobOrder j WHERE j.hospitalDevice.site.id = " +
	 * siteId + " AND MONTH(j.jobOrderDate) = " + month +
	 * " AND YEAR(j.jobOrderDate) = " + year;
	 * 
	 * return dbQueryManager.getJPQLSingleResult(jpql, null, Integer.class); }
	 */

}
